package com.example.springbootasync.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;


@Service
public class AsyncService {

    @Async("pool1")
    public void add() throws InterruptedException {
        for (int i = 0; i < 20; i++) {
            System.out.println("add方法" + i);
            Thread.sleep(1000);
        }
    }

    @Async("pool2")
    public void sub() throws InterruptedException {
        for (int i = 20; i > 0; i--) {
            System.out.println("sub方法" + i);
            Thread.sleep(1000);
        }
    }

}
